<?php

namespace App\Http\Middleware\Task;

use Closure;
use Illuminate\Http\Request;
use App\Http\FormatReturn;

class Intranet
{
    use FormatReturn;
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @param  string|null  ...$guards
     * @return mixed
     */
    public function handle(Request $request, Closure $next)
    {
        $ip=filter_var($request->getClientIp(), FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE);
        if( !$ip ){
            return $next($request);
        }else{
            //return $next($request);
            return $this->fail('5000',$ip);
        }
    }
}
